package com.hwua.view;

import com.hwua.domain.User;
import com.hwua.service.UserService;
import com.hwua.serviceimpl.UserServiceImpl;
import com.hwua.util.InputTools;

import java.util.List;

/**
 * 用户查看个人信息界面
 * @author admin
 */
public class UserInformationView extends AbstractView{
    private String name;
    private String pwd;
    public UserInformationView(String name,String pwd){
        this.name=name;
        this.pwd=pwd;
    }
    @Override
    public AbstractView showView() {
        UserService us = new UserServiceImpl();
        List<User> userList = us.login(name, pwd);
        for (User user : userList) {
            System.out.println("=================<<<个人资料>>>================");
            System.out.println("用户id："+user.getUserId());
            System.out.println("-----------------------------------------------");
            System.out.println("用户名："+user.getUserName());
            System.out.println("-----------------------------------------------");
            System.out.println("密码："+user.getUserPwd());
            System.out.println("-----------------------------------------------");
            System.out.println("VIP等级："+user.getUserLevel());
            System.out.println("-----------------------------------------------");
        }
        System.out.println();
        System.out.println("1.返回主界面   2.退出：");
        int i = InputTools.checkIntInput(1, 2);
        if(i==1){
            nextView=new UserView(name,pwd);
        }else if (i==2){
            nextView=null;
        }
        return nextView;
    }
}
